import sys

def parse_headers(filename):
    f = open(filename)
    for line in f.readlines():
        if line.startswith("## for <"):
            featureStart = line.find("<") + 1
            featureEnd = line.find(">")
            featureId = line[featureStart:featureEnd]

            valuesStart = line.find("[") + 1
            valuesEnd = line.find("]")
            values = line[valuesStart:valuesEnd]

            print "\n[%s]" % (featureId)
            featureValueArray = []
            for featureIdx, rawValue in enumerate(values.split(",")):
                featureValue = rawValue.strip().replace("'", "").replace("\"", "")
                print "%s=%d" % (featureValue, featureIdx+1)

if __name__ == "__main__":
    if len(sys.argv) > 1:
        parse_headers(sys.argv[1])
        exit(0)

    print "Usage: parse_pairwise_headers.py FILENAME"
    exit(-1)


